﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AAA.Meta.Chart;
using AAA.Meta.Chart.Data;
using AAA.Meta.Chart.Util;
using AAA.DesignPattern.Observer;

namespace AAA.Chart.Component
{
    public partial class ProfileVTChart : ProfileChartBase, IObserver
    {
        private Dictionary<float, Dictionary<int, float>> _dicCellData1 = new Dictionary<float, Dictionary<int,float>>();
        private Dictionary<float, List<int>> _dicVTSeq = new Dictionary<float, List<int>>();
        private DateTime dtXStartIndex;
        private DateTime dtXEndIndex;
        private float fAxisYBoxWidth = 0;
        private float fAxisXInterval = 1000;
        private float fAxisXMin = 0;
        private float fAxisXMax = 10;
        private float _fLastPrice;
        private bool _blShowYAxis = false;
        private int _iChartType = 0; //0 Volume, 1 Tick
        private int _iChartMode = 0; //0 Normal Today, 1 Accumulate, 2 Range Mode
        private Point Mouse_Pos = new Point();

        public ProfileVTChart()
        {
            InitializeComponent();
            BackColor = Color.White;
            MessageSubject.Instance().Subject.Attach(this);
        }

        public bool ShowYAxis
        {
            get { return _blShowYAxis; }
            set { _blShowYAxis = value; }
        }
        
        public float AxisXInterval
        {
            get { return fAxisXInterval; }
            set { fAxisXInterval = value; }
        }

        public int ChartType
        {
            get { return _iChartType; }
            set { _iChartType = value; }
        }

        public float SetScale
        {
            get { return fScale; }
            set { fScale = value; }
        }

        public DateTime XStartIndex
        {
            get { return dtXStartIndex; }
            set { dtXStartIndex = value; }
        }

        public DateTime XEndIndex
        {
            get { return dtXEndIndex; }
            set { dtXEndIndex = value; }
        }

        public int ChartMode
        {
            get { return _iChartMode; }
        }

        public float AxisXAreaHeight
        {
            get
            {
                Graphics g = CreateGraphics();
                fAxisXAreaHeight = (g.MeasureString("0\n0\n0", _ChartFont).Height) * fScale;
                g.Dispose();
                return fAxisXAreaHeight;
            }
        }

        public float AxisYBoxWidth
        {
            get
            {
                if (ShowYAxis)
                {
                    Graphics g = CreateGraphics();
                    fAxisYBoxWidth = (g.MeasureString("000,000.00", _ChartFont).Width) * fScale;
                    g.Dispose();
                    return fAxisYBoxWidth;
                }
                else
                {
                    return 0;
                }
            }
        }

        public override void AddProfileMgr(ProfileMgr pmProfileMgr)
        {
            try
            {
                float _fPriceInterval = pmProfileMgr.PriceInterval;
                float fHighest;
                float fLowest;
                int iCharCount;
                int iRowIndex;
                List<float> lstPrice;
                _lstCellPrice.Clear();
                _dicCellData1.Clear();
                _dicVTSeq.Clear();

                // Calculate price range and character range
                fHighest = -float.MaxValue;
                fLowest = float.MaxValue;
                iCharCount = 0;

                fHighest = pmProfileMgr.Highest();
                fLowest = pmProfileMgr.Lowest();
                iCharCount = pmProfileMgr.POCTPOCount();

                fHighest = (float)(Math.Ceiling(fHighest / _fPriceInterval) * _fPriceInterval) + 2 * _fPriceInterval;
                fLowest = (float)(Math.Floor(fLowest / _fPriceInterval) * _fPriceInterval) - 2 * _fPriceInterval;
                _iPriceCount = (int)((fHighest - fLowest) / _fPriceInterval) + 1;
                for (float fIndex = fHighest; fIndex >= fLowest; fIndex -= _fPriceInterval)
                {
                    _dicCellData1.Add(fIndex, new Dictionary<int,float>());
                    _lstCellPrice.Add(fIndex);
                }
                List<ProfileData> _lstProfile = pmProfileMgr.GetProfileData(pmProfileMgr.StartTime, pmProfileMgr.EndTime);
                _fLastPrice = pmProfileMgr.GetLastPrice();

                fAxisXMin = 0;
                fAxisXMax = 1;
                Dictionary<float, float> fSum = new Dictionary<float, float>();
                for (int intProfileIndex = 0; intProfileIndex < _lstProfile.Count; intProfileIndex++)
                {
                    ProfileData dayProfile = _lstProfile[intProfileIndex];
                    lstPrice = dayProfile.PriceList;
                    for (int i = 0; i < lstPrice.Count; i++)
                    {
                        float fmaxValue = 0;
                        if (!fSum.ContainsKey(lstPrice[i]))
                        {
                            fSum.Add(lstPrice[i], 0);
                        }
                        if ((dayProfile.StartTime.Ticks >= XStartIndex.Ticks) && (dayProfile.StartTime.Ticks <= XEndIndex.Ticks))
                        {
                            iRowIndex = (int)((fHighest - lstPrice[i]) / _fPriceInterval);
                            switch (ChartType)
                            {
                                case 0:
                                    _dicCellData1[_lstCellPrice[iRowIndex]].Add(intProfileIndex, dayProfile.VolumeAtPrice(_lstCellPrice[iRowIndex], XStartIndex, XEndIndex));
                                    break;
                                case 1:
                                    _dicCellData1[_lstCellPrice[iRowIndex]].Add(intProfileIndex, dayProfile.TickAtPrice(_lstCellPrice[iRowIndex], XStartIndex, XEndIndex));
                                    break;
                            }
                        }
                        List<float> lstMaxVT = new List<float>();
                        switch (ChartType)
                        {
                            case 0:
                                fSum[lstPrice[i]] = fSum[lstPrice[i]] + dayProfile.VolumeAtPrice(lstPrice[i]);
                                /*lstMaxVT = dayProfile.GetMaxVolumePrice();
                                if ((!_dicVTSeq.ContainsKey(lstPrice[i])) && (lstMaxVT[0] == lstPrice[i]))
                                {
                                    _dicVTSeq.Add(lstMaxVT[0], new List<int>());
                                    _dicVTSeq[lstMaxVT[0]].Add(intProfileIndex);
                                }*/
                                break;
                            case 1:
                                fSum[lstPrice[i]] = fSum[lstPrice[i]] + dayProfile.TickAtPrice(lstPrice[i]);
                                /*lstMaxVT = dayProfile.GetMaxTickPrice();
                                if ((!_dicVTSeq.ContainsKey(lstPrice[i])) && (lstMaxVT[0] == lstPrice[i]))
                                {
                                    _dicVTSeq.Add(lstMaxVT[0], new List<int>());
                                    _dicVTSeq[lstMaxVT[0]].Add(intProfileIndex);
                                }*/
                                break;
                        }
                    }
                    float fProfileAccMax = 0;
                    float fProfileAccMaxIndex = -1;
                    foreach (float fKey in fSum.Keys) {
                        if (fSum[fKey] >= fProfileAccMax) {
                            fProfileAccMax = fSum[fKey];
                            fProfileAccMaxIndex = fKey;
                        }
                    }
                    if (!_dicVTSeq.ContainsKey(fProfileAccMaxIndex)) {
                        _dicVTSeq.Add(fProfileAccMaxIndex, new List<int>());
                    }
                    _dicVTSeq[fProfileAccMaxIndex].Add(intProfileIndex);
                }
                foreach (float fIndex in fSum.Keys)
                {
                    fAxisXMax = Math.Max(fSum[fIndex], fAxisXMax);
                    fAxisXMin = Math.Min(fSum[fIndex], fAxisXMin);
                }
                _ProfileMgr = pmProfileMgr;
                //PaintChart();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
            }
        }

        public override void PaintChart()
        {
            try
            {
                Graphics g;
                Graphics eg = CreateGraphics();
                _ChartFont = AAA.Base.Util.Graphic.FontUtil.CreateFont(eg, "細明體", FontStyle.Regular, "W", (int)BoxHeight, (int)BoxWidth);
                Bitmap bitmap = new Bitmap(Width, Height);
                g = Graphics.FromImage(bitmap);
                g.Clear(BackColor);
                DrawPYAxis(g);
                eg.DrawImage(bitmap, 0, 0);
                eg.Dispose();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
            }
        }

        private void DrawPYAxis(Graphics g)
        {
            if (_ProfileMgr == null)
            {
                return;
            }
            try
            {
                int Price_Length = Convert.ToInt32(Math.Ceiling((Size.Height - AxisXAreaHeight) / fBoxHeight * fScale));
                if (ShowYAxis)
                {
                    g.DrawLine(new Pen(new SolidBrush(AxisColor), 1), AxisYBoxWidth + 2, 0, AxisYBoxWidth + 2, Height - AxisXAreaHeight);
                }
                int LabelCount = 999;
                int LabelMulti = 1;
                while (LabelCount >= 3)
                {
                    AxisXInterval = 100 * LabelMulti;
                    LabelCount = (int)Math.Ceiling(fAxisXMax / AxisXInterval);
                    LabelMulti++;
                }
                for (int I = (int)YStartIndex; I < YEndIndex; I++)
                {
                    if ((I < _lstCellPrice.Count) & (I >= 0))
                    {
                        float[] dashValues = { 1, 1 };
                        Pen dashPen = new Pen(GridColor, 1);
                        dashPen.DashPattern = dashValues;
                        if (_lstCellPrice[I] == ProfileUtil.CalPriceLabel(_ProfileMgr.PriceInterval, _fLastPrice))
                        {
                            g.FillRectangle(new SolidBrush(HighlightColor), AxisYBoxWidth + 4, ((I - YStartIndex) + (float) 0.75) * fBoxHeight * fScale, Width, fBoxHeight * (float)0.25 * fScale);
                        }
                        g.DrawLine(dashPen, AxisYBoxWidth, (I - YStartIndex + 1) * fBoxHeight * fScale, Width, (I - YStartIndex + 1) * fBoxHeight * fScale);
                        if (ShowYAxis)
                        {
                            StringFormat strYAxisFormat = new StringFormat();
                            strYAxisFormat.Alignment = StringAlignment.Far;
                            g.DrawString(String.Format("{0:##,##0.00;(##,##0.00);Zero}", _lstCellPrice[I]), _ChartFont, new SolidBrush(AxisLineColor), new RectangleF(0, (I - YStartIndex) * fBoxHeight * fScale, fAxisYBoxWidth, fBoxHeight * fScale), strYAxisFormat);
                        }
                        //List<Dictionary<int,float>> lstSum =  CalValueSum(_dicCellData1[_lstCellPrice[I]]);
                        float fStartX = ValueToPixel(0, I)[0];
                        int intSumIndex = 0;
                        foreach (int intKey in _dicCellData1[_lstCellPrice[I]].Keys)
                        {
                            if (intSumIndex == (_dicCellData1[_lstCellPrice[I]].Keys.Count - 1))
                            {
                                fStartX = DrawBox(g, fStartX, ValueToPixel(0, I)[1], _cStackColors[intKey % _cStackColors.Length], _dicCellData1[_lstCellPrice[I]][intKey].ToString(), true);
                            }
                            else
                            {
                                fStartX = DrawBox(g, fStartX, ValueToPixel(0, I)[1], _cStackColors[intKey % _cStackColors.Length], _dicCellData1[_lstCellPrice[I]][intKey].ToString(), false);
                            }
                            intSumIndex++;
                        }
                        /*for (int intSumIndex = lstSum.Count - 1; intSumIndex >= 0; intSumIndex--)
                        {
                            Dictionary<int, float> dicSum = lstSum[intSumIndex];
                            foreach(int intKey in dicSum.Keys) {
                                if (intSumIndex == (lstSum.Count - 1))
                                {
                                    fStartX = DrawBox(g, fStartX, ValueToPixel(0, I)[1], _cStackColors[intKey % _cStackColors.Length], lstSum[intSumIndex][intKey].ToString(), true);
                                }
                                else {
                                    fStartX = DrawBox(g, fStartX, ValueToPixel(0, I)[1], _cStackColors[intKey % _cStackColors.Length], lstSum[intSumIndex][intKey].ToString(), false);
                                }
                            }
                        }*/
                        //DrawBox(g, ValueToPixel(0, I)[0], ValueToPixel(0, I)[1], BoxColor, lstSum[lstSum.Count - 1].ToString(), true);
                        if ((_dicVTSeq.ContainsKey(_lstCellPrice[I])) && (ChartMode == 1)) {
                            string SeqStr = "";
                            foreach (float intSeq in _dicVTSeq[_lstCellPrice[I]]) { 
                                if (SeqStr != "") {
                                    SeqStr = SeqStr + " ";
                                }
                                SeqStr = SeqStr + (intSeq + 1).ToString();
                            }
                            g.DrawString(SeqStr, _ChartFont, new SolidBrush(Color.Black), new Point((int)(Width - g.MeasureString(SeqStr, _ChartFont).Width * fScale), (int)ValueToPixel(0, I)[1]));
                        }
                    }
                }
                g.FillRectangle(new SolidBrush(BackColor), AxisYBoxWidth, Height - AxisXAreaHeight, Width, Height);
                g.DrawLine(new Pen(new SolidBrush(AxisColor), 1), AxisYBoxWidth, Height - AxisXAreaHeight, Width, Height - AxisXAreaHeight);
                DrawXAxis(g);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
            }
        }

        private float DrawBox(Graphics g, float X, float Y, Color DrawColor, String strChar, bool ShowString)
        {
            float fStartX = X;
            try
            {
                float fBarWidth = 8;
                if (ShowYAxis)
                {
                    fBarWidth = (float.Parse(strChar) / fAxisXMax) * (Width - AxisYBoxWidth - 54);
                }
                else
                {
                    fBarWidth = (float.Parse(strChar) / fAxisXMax) * (Width - 54);
                }
                if (strChar != "0")
                {
                    g.FillRectangle(new SolidBrush(DrawColor), X, Y + 2, fBarWidth * fScale, (fBoxHeight - 4) * fScale);
                    g.DrawRectangle(new Pen(new SolidBrush(AxisLineColor), 1), X, Y + 2, fBarWidth * fScale, (fBoxHeight - 4) * fScale);
                    if (ShowString)
                    {
                        //g.DrawString(strChar, _ChartFont, new SolidBrush(Color.Black), new Point((int)X + (int)(fBarWidth * fScale) + 4, (int)Y + 1));
                    }
                }
                fStartX = fStartX + fBarWidth * fScale;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
            }
            return fStartX;
        }

        public int[] ValueToPixel(double dX, double dY)
        {
            int[] iReturn = new int[2];
            try
            {
                iReturn[0] = 4;
                if (ShowYAxis)
                {
                    iReturn[0] = (int)(fAxisYBoxWidth + iReturn[0]);
                }
                iReturn[1] = (int)((dY - fYStartIndex) * fBoxHeight * fScale);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
            }
            return iReturn;
        }

        private void DrawXAxis(Graphics g)
        {
            try
            {
                //AxisXInterval = 5000;
                float fTickInterval = 100000;
                float iXTickMin = Math.Max((int)Math.Floor(fAxisXMin / fAxisXInterval), 0) * fAxisXInterval;
                float iXTickMax = (float)Math.Ceiling(fAxisXMax / fAxisXInterval) * fAxisXInterval;
                int iTickY1 = (int)(Height - AxisXAreaHeight + 2);
                int iTickY2 = iTickY1 + 8;
                for (float intI = iXTickMin; intI <= iXTickMax; intI = intI + fAxisXInterval)
                {
                    if (ShowYAxis)
                    {
                        fTickInterval = ((float)intI / ((float)iXTickMax - (float)iXTickMin)) * (Width - AxisYBoxWidth - 54);
                        fTickInterval = AxisYBoxWidth + 4 + fTickInterval;
                    }
                    else
                    {
                        fTickInterval = 4 + ((float)intI / ((float)iXTickMax - (float)iXTickMin)) * (Width - 54);
                    }
                    g.DrawLine(new Pen(new SolidBrush(AxisColor)), fTickInterval, iTickY1, fTickInterval, iTickY2);
                    g.DrawString(intI.ToString(), _ChartFont, new SolidBrush(AxisColor), new Point((int)fTickInterval - 2, (int)iTickY1 + 10));
                    g.DrawString(XStartIndex.ToString(), _ChartFont, new SolidBrush(AxisColor), new Point(10, iTickY1 + (int)(AxisXAreaHeight * 1 / 3 + 6)));
                    g.DrawString(XEndIndex.ToString(), _ChartFont, new SolidBrush(AxisColor), new Point(10, iTickY1 + (int)(AxisXAreaHeight * 2 / 3)));
                }
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message.ToString());
            }
        }

        public void ResetRange(ProfileMgr profile_mgr)
        {
            try {
                XStartIndex = profile_mgr.StartTime;
                XEndIndex = profile_mgr.EndTime;
                if (_iChartMode == 0) {
                    XStartIndex = _ProfileMgr.GetLastProfile().StartTime;
                }
                AddProfileMgr(profile_mgr);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
            }
        }

        private List<Dictionary<int, float>> CalValueSum(Dictionary<int,float> dicValues) {
            List<Dictionary<int, float>> Result = new List<Dictionary<int, float>>();
            try
            {
                float fTValue = 0;
                foreach (int intKey in dicValues.Keys)
                {
                    fTValue = fTValue + dicValues[intKey];
                    Dictionary<int, float> dicTValue = new Dictionary<int, float>();
                    dicTValue.Add(intKey, fTValue);
                    Result.Add(dicTValue);
                }
                if (Result.Count() == 0)
                {
                    Dictionary<int, float> dicTValue = new Dictionary<int, float>();
                    dicTValue.Add(0, fTValue);
                    Result.Add(dicTValue);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
            } 
            return Result;
        }

        public void SetLastDayProfile() {
            try {
                if ((_ProfileMgr != null ) && (_ProfileMgr.GetPriceList().Count() != 0)) {
                    XStartIndex = _ProfileMgr.GetLastProfile().StartTime;
                    XEndIndex = _ProfileMgr.GetLastProfile().EndTime;
                    AddProfileMgr(_ProfileMgr);
                }
            }
            catch (Exception ex) {
                Console.WriteLine(ex.Message.ToString());
            }
        }

        #region IObserver Members

        void IObserver.Update(object oSource, IMessageInfo miMessage)
        {
            List<DateTime> SelectProfileIndex = new List<DateTime>();
            switch (miMessage.MessageSubject)
            {
                case "VolumeRangeChanged":
                    SelectProfileIndex = (List<DateTime>)miMessage.Message;
                    if (SelectProfileIndex[1].Ticks <= SelectProfileIndex[3].Ticks)
                    {
                        XStartIndex = SelectProfileIndex[1];
                        XEndIndex = SelectProfileIndex[3];
                    }
                    else
                    {
                        XStartIndex = SelectProfileIndex[3];
                        XEndIndex = SelectProfileIndex[1];
                    }
                    _iChartMode = 2;
                    AddProfileMgr(_ProfileMgr);
                    break;
                case "ProfileMgrChanged":
                    AddProfileMgr((ProfileMgr)miMessage.Message);
                    break;
                case "VTChartModeChanged":
                    Dictionary<string, object> RecvMsg = (Dictionary<string, object>)miMessage.Message;
                    _iChartMode = (int)RecvMsg["ChartMode"];
                    SelectProfileIndex.Clear();
                    SelectProfileIndex.Add((DateTime)RecvMsg["StartTime"]);
                    SelectProfileIndex.Add((DateTime)RecvMsg["EndTime"]);
                    if (SelectProfileIndex[0].Ticks <= SelectProfileIndex[1].Ticks)
                    {
                        XStartIndex = SelectProfileIndex[0];
                        XEndIndex = SelectProfileIndex[1];
                    }
                    else
                    {
                        XStartIndex = SelectProfileIndex[1];
                        XEndIndex = SelectProfileIndex[0];
                    } 
                    AddProfileMgr(_ProfileMgr);
                    break;
                case "ChartCrossMoved":
                    List<string> CrossPostion = (List<string>)miMessage.Message;
                    if (Name != CrossPostion[0])
                    {
                        MoveCrossLine(int.Parse(CrossPostion[1]), int.Parse(CrossPostion[2]), 0);
                    }
                    break;
                /*case "CrossClick":
                    List<object> M_Pos = (List<object>)miMessage.Message;
                    if ((string)M_Pos[0] != Name)
                    {
                        ProfileVTChart_MouseClickAction((MouseEventArgs)M_Pos[1], Mouse_Pos.X, Mouse_Pos.Y);
                    }
                    break;*/
                case "ChartCrossInvisible":
                    string SenderName = (string)miMessage.Message;
                    if (SenderName != Name)
                    {
                        SetCrossLineVisible(false);
                    }
                    break;
            }
        }

        #endregion

        private void smiAccumulate_Click(object sender, EventArgs e)
        {
            SetChartMode(1);
        }

        private void smiToday_Click(object sender, EventArgs e)
        {
            SetChartMode(0);
        }

        private void SetChartMode(int iChartMode) {
            _iChartMode = iChartMode;
            try
            {
                IMessageInfo miMessage = new MessageInfo();
                miMessage.MessageTicks = DateTime.Now.Ticks;
                miMessage.MessageSubject = "VTChartModeChanged";
                Dictionary<string, object> SelectProfileIndex = new Dictionary<string, object>();
                switch (iChartMode)
                {
                    case 0: 
                        SelectProfileIndex.Add("ChartMode", _iChartMode);
                        SelectProfileIndex.Add("StartTime", _ProfileMgr.GetLastProfile().StartTime);
                        SelectProfileIndex.Add("EndTime", _ProfileMgr.GetLastProfile().EndTime);
                        break;
                    case 1:
                         SelectProfileIndex.Add("ChartMode", _iChartMode);
                        SelectProfileIndex.Add("StartTime", _ProfileMgr.StartTime);
                        SelectProfileIndex.Add("EndTime", _ProfileMgr.EndTime); 
                        break;
                }
                if (SelectProfileIndex.Count == 3)
                {
                    miMessage.Message = SelectProfileIndex;
                    MessageSubject.Instance().Subject.Notify(miMessage);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "," + ex.StackTrace);
            }        
        }

        private void ProfileVTChart_MouseClick(object sender, MouseEventArgs e)
        {
            ProfileVTChart_MouseClickAction(e, e.X, e.Y);
        }

        private void ProfileVTChart_MouseClickAction(MouseEventArgs e, int X, int Y)
        {
            try
            {
                if (e.Button == MouseButtons.Right)
                {
                    cMenuS1.Show(this, new Point(X, Y));
                }
                else {
                    MoveAndShowCross();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
            }
        }

        public void Chart_ZoomInOut(int intChange)
        {
            try {
                BoxHeight = BoxHeight + intChange;
                BoxWidth = BoxWidth + intChange;
                PaintChart();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message.ToString());
            }
        }

        private void ProfileVTChart_MouseMove(object sender, MouseEventArgs e)
        {
            try
            {
                Mouse_Pos.X = e.X;
                Mouse_Pos.Y = e.Y;
                SetCrossLineVisible(false);
               /* MoveCrossLine(e.X, e.Y, 1);
                IMessageInfo miMessage = new MessageInfo();
                miMessage.MessageTicks = DateTime.Now.Ticks;
                miMessage.MessageSubject = "ChartCrossMoved";
                List<string> CrossPostion = new List<string>();
                CrossPostion.Add(Name);
                CrossPostion.Add(e.X.ToString());
                CrossPostion.Add(e.Y.ToString());
                miMessage.Message = CrossPostion;
                MessageSubject.Instance().Subject.Notify(miMessage);*/
                IMessageInfo miMessage = new MessageInfo();
                miMessage.MessageTicks = DateTime.Now.Ticks;
                miMessage.MessageSubject = "ChartCrossInvisible";
                miMessage.Message = Name;
                MessageSubject.Instance().Subject.Notify(miMessage);
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }

        private void MoveAndShowCross()
        {
            try
            {
                MoveCrossLine(Mouse_Pos.X, Mouse_Pos.Y, 1);
                IMessageInfo miMessage = new MessageInfo();
                miMessage.MessageTicks = DateTime.Now.Ticks;
                miMessage.MessageSubject = "ChartCrossMoved";
                List<string> CrossPostion = new List<string>();
                CrossPostion.Add(Name);
                CrossPostion.Add(Mouse_Pos.X.ToString());
                CrossPostion.Add(Mouse_Pos.Y.ToString());
                miMessage.Message = CrossPostion;
                MessageSubject.Instance().Subject.Notify(miMessage);
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }
    }
}
